package com.itheima.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.domain.Student;
import com.itheima.mapper.StudentMapper;
import com.itheima.service.StudentService;
import com.itheima.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class StudentServiceImpl implements StudentService {

    private StudentMapper proxyStudentMapper = null;


    @Override
    public PageInfo findPage(int pageNum, int pageSize) {
        //在查询所有之前，要设置分页信息
        PageHelper.startPage(pageNum,pageSize);
        //分页查询结果集
        List<Student> students = proxyStudentMapper.findAll();
        //返回
        return new PageInfo(students);
    }

    @Override
    public List<Student> findAll() {
        return proxyStudentMapper.findAll();
    }

    @Override
    public Student findById(String id) {
        return proxyStudentMapper.findById(id);
    }

    @Override
    public void save(Student student) {
        proxyStudentMapper.save(student);
    }

    @Override
    public void update(Student student) {
        proxyStudentMapper.update(student);
    }

    @Override
    public void delete(String id) {
        proxyStudentMapper.delete(id);
    }
}
